package com.wn.controller;

import com.wn.entity.Permission;
import com.wn.entity.ResponseEntity;
import com.wn.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/rbac_permission")
public class PermissionrController {
    @Autowired
    PermissionService permissionService;

    @RequestMapping("addOne")
    public ResponseEntity addOne(@RequestBody Permission permission) {
        permissionService.addOne(permission);
        return ResponseEntity.SUCCESS;
    }

    @RequestMapping("deleteOne")
    public ResponseEntity deleteOne(@RequestBody Permission permission) {
        permissionService.deleteOne(permission);
        return ResponseEntity.SUCCESS;
    }

    @RequestMapping("update")
    public ResponseEntity update(@RequestBody Permission permission) {
        permissionService.update(permission);
        return ResponseEntity.SUCCESS;
    }

    @RequestMapping("findAll")
    public ResponseEntity findAll() {
        List<Permission> permissions = permissionService.findAll();
        return new ResponseEntity(200, "成功", permissions);
    }
}


